package com.myinterview.intest;

public class BetaStringProcessor extends StringProcessor {

    public BetaStringProcessor(String rawString) {
        super(rawString);
        this.inString = rawString.toLowerCase();
        System.out.println("BetaStringProcessor input raw string: " + this.inString);
    }

    public char getPreviousAlphabet(char alpha) {
        String Letters = "abcdefjhijklmnopqrstuvwxyz";
        int index = Letters.indexOf(alpha);
        char hitChar;
        if (index == 0){
            hitChar = alpha;
        } else {
            hitChar = Letters.charAt(index-1);
        }
        return hitChar;
    }
    public String charProcessor(String inString, int currentIndex) {
        StringBuilder builderString = new StringBuilder(inString);
        String processString;
        char currentChar = builderString.charAt(currentIndex);
        for (int i=processLength; i >1; i--) {
            builderString.deleteCharAt(currentIndex);
        };
        if (currentChar == 'a') {
            builderString.deleteCharAt(currentIndex);
            processString = builderString.toString();
        } else {
            char replaceChar = getPreviousAlphabet(currentChar);
            processString = builderString.toString().replace(builderString.charAt(currentIndex), replaceChar);
        }
        return processString;
    }
}